package com.hongdee.insurance.quotation.mapper;

import com.hongdee.insurance.quotation.pojo.TInsuranceQuotationItemPojo;
import com.hongdee.insurance.quotation.pojo.TInsuranceQuotationPojo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface ITInsuranceQuotationMapper {

    /**
     * 保存报价单信息
     * @param quotation
     */
    @Insert("INSERT INTO `t_insurance_quotation` ( `id`,`create_time`, `create_user`, `car_id`, " +
            "`commercialinsurance_total`, `company_id`, `compulsory_total`, `contact_people`, `contact_phone`, " +
            "`insurance_company_id`, `insurance_start_date`, `insurance_stop_date`, `insure_type`, `iscompulsoryinsurance`," +
            "`plate_num`, `status`, `vin`) " +
            "VALUES " +
            "(#{id},#{createTime}, #{createUser},#{carId},#{commercialinsuranceTotal}," +
            "#{companyId},#{compulsoryTotal},#{contactPeople},#{contactPhone}," +
            "#{insuranceCompanyId},#{insuranceStartDate},#{insuranceStopDate},#{insureType}," +
            "#{iscompulsoryinsurance},#{plateNum},#{status},#{vin} )")
    void saveQuotation(TInsuranceQuotationPojo quotation);

    /**
     * 保存保险项目
     * @param item
     */
    @Insert("INSERT INTO `crm`.`t_insurance_quotation_item` (`id`, `create_time`, `company_id`, `item_id`, " +
            "`item_limit`, `item_name`, `item_price`, `quotation_id`, `type`) " +
            "VALUES " +
            "(replace(uuid(),'-',''),#{createTime},#{companyId},#{itemId},#{itemLimit},#{itemName}," +
            "#{itemPrice},#{quotationId},#{type})")
    void saveQuotationItem(TInsuranceQuotationItemPojo item);

    @Delete("delete from t_insurance_quotation_item where quotation_id=#{qId}")
    void delQuotationItemByQId(String qId);
}
